﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PSE.ProcessManager.Server.Process.Security;
using Sinacor.Infra.Service.Common;
using Sinacor.Infra.Core.ProcessManager.Server.Security;
using Sinacor.Infra.Service.Security.Services;


namespace Sinacor.Process.Bovespa.ControleMovimentoBolsa.Server.Communication
{
    public class Acesso : BaseCommunication
    {
        #region Construtor
        public Acesso()
            : base(AuthenticationContext<SinacorAuthenticationData>.Current.AuthenticationData.LoginName, AuthenticationContext<SinacorAuthenticationData>.Current.AuthenticationData.Password, AuthenticationContext<SinacorAuthenticationData>.Current.AuthenticationData.CompanyId)
        {
        }
        #endregion

        #region Métodos
        /// <summary>
        /// Verifica se um determinado sistema esta instalado
        /// </summary>
        public bool VerificarSistemaInstalado(string sistema)
        {
            Bovespa.Acesso.Acesso.IAcesso verificarsistemainstalado = null;
            bool retorno = false;

            try
            {
                using (ServiceInstance<Bovespa.Acesso.Acesso.IAcesso> service = new ServiceInstance<Bovespa.Acesso.Acesso.IAcesso>())
                {
                    verificarsistemainstalado = service.TryGetInstance(this.LoginName, this.Password, this.CompanyId);
                    retorno = verificarsistemainstalado.VerificarSistemaInstalado(sistema);
                }
            }
            catch (Exception ex)
            {
                base.HandleFault(ex);
            }

            return retorno;
        }
        #endregion
    }

}